﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WTwitter.Model.UserData;
using WTwitter.Model.Framework;
using WTwitter.Model.Utility;
using WTwitter.Model.Twitter.Json;

namespace WTwitter.Model.Twitter.Utility {
	static class SocialGraphMethod {
		private static readonly string FriendsIdsUrl = "http://api.twitter.com/1/friends/ids.json";
		private static readonly string FollowersIdsUrl = "http://api.twitter.com/1/followers/ids.json";

		/// <summary>
		/// 
		/// </summary>
		/// <param name="info"></param>
		/// <param name="searchTarget">調べる対象のユーザー</param>
		/// <returns>searchTargetがフォローしているユーザーIDのリスト</returns>
		public static List<long> FriendsIds(AuthInfo info, IUser searchTarget) {
			var result = WebUtility<IdList>.GetDeserializedJsonData(FriendsIdsUrl, "GET",
				new RequestParameter[] { 
					new RequestParameter("screen_name", searchTarget.ScreenName),
					new RequestParameter("cursor", "-1")
				}, info);
			return result.Ids;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="info"></param>
		/// <param name="searchTarget"></param>
		/// <returns>searchTargetをフォローしているユーザーIDのリスト</returns>
		public static List<long> FollowersIds(AuthInfo info, IUser searchTarget) {
			var result = WebUtility<IdList>.GetDeserializedJsonData(FollowersIdsUrl, "GET",
				new RequestParameter[] {
					new RequestParameter("screen_name", searchTarget.ScreenName),
					new RequestParameter("cursor", "-1")
				}, info);
			return result.Ids;
		}
	}
}
